package com.entrogy.dao;


import com.entrogy.bean.AddRoleEntity;
import com.entrogy.bean.PermissionAndMenu;
import com.entrogy.bean.Role;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
public interface RoleMapper {

    List<Role> findRoles(@Param(value = "roleName") String roleName, @Param(value = "schoolCode") int schoolCode);

    int updateRole(@Param(value = "roleId") int roleId, @Param(value = "pIds") List<Integer> pIds);

    int deleteRolesPermission(int roleId);

    int discardRoleById(Integer roleId);

    int enableRoleById(Integer roleId);

    List<Role> findAllRolesSimple(Integer schoolCode);

    int addRole(AddRoleEntity addRole);

    int addRoleAndPermission(@Param(value = "roleId") int roleId, @Param(value = "pId") Integer pId);

    List<PermissionAndMenu> findAllPermission(@Param(value = "schoolCode") Integer schoolCode);

    int deleteRolesMenu(int roleId);

    List<Integer> findPermissionsMenuIds(int roleId);

    int insertChildMenus(@Param(value = "roleId") int roleId, @Param(value = "menuIds") List<Integer> menuIds);

    List<Integer> findMenusParentMenuIds(List<Integer> menuIds);

    /**
     *  查询管理员获得的所有角色
     * @return
     */
    List<Role> selectAllRoles();

    List<Role> findRolesByUsername(String username);

    Role findRoleByRoleId(Integer roleId);

    List<Integer> listRoleId(String userId);

    /**
     * 根据用户id查询角色信息
     * @param teacherId
     * @return
     */
    List<Role> findRolesByUserId(String teacherId);

    /**
     * 查询拥有某些权限的所有角色
     * @param permissionCode
     * @param schoolCode
     * @return
     */
    List<Integer> listHasSomePermissionRole(@Param("permissionCode") String permissionCode, @Param("schoolCode") Integer schoolCode);
}
